<?
if(isset($_GET['method']))
{
	$method = $_GET['method'];
	if($method=="del"){
		$sListId="";
		if(isset($_POST["chon"]))$sListId=$_POST["chon"];
		$sql="delete from ".$prefix."tintuc_comment where cm_id in('".str_replace(",","','",$sListId)."')";
		mysql_query($sql);
		Redirect("Bạn đã xoá thành công","?mod=news.listcomment");
	}
	else if($method=="delete"){
		$sListId=$_GET["id"];
		$sql="delete from ".$prefix."tintuc_comment where cm_id=$sListId";
		mysql_query($sql);
		Redirect("Bạn đã xoá thành công","?mod=news.listcomment");
	}
}
$where = "";
if(isset($_GET['catid']))
{
	$catid = $_GET['catid'];
	$where .=" where t_loaisanpham=$catid";
}
else if(isset($_GET['location'])){
	$location = $_GET['location'];
	$where .=" where t_tinhthanh=$location";
}else if(isset($_GET['act'])){
	$act = $_GET['act'];
	$where .= " where t_hienthi=$act";
}else if(isset($_GET['hot'])){
	$hot = $_GET['hot'];
	$where .= " where t_noibat=$hot";
}else{
	$where = $where;
}
	///////Paging
	$strSQL = "select * from ".$prefix."tintuc_comment".$where." order by cm_date DESC";
	$pp=10; 
	$parr=array();
	$parr=paging($strSQL,$pp);
	$page=$parr[0];
	$limitvalue=$parr[1];
	$numofpages=$parr[2];
	$strSQL.=" LIMIT $limitvalue, $pp";
	$rs = mysql_query($strSQL) or die('Not query');
	$i=0;
	$isexits=false;
	
	if(mysql_num_rows($rs)) $isexits=true;
?>
<div class="newsList-path"></div>
	<div style="margin-bottom:5px; font-size:14px;">
	<?
	$sql = "select count(*) as total from ".$prefix."tintuc_comment".$where."";
	$result = mysql_query($sql) or die("Can't connect database");
	$row = mysql_fetch_array($result);
	?>
	 Có <?=$row['total']?> commnet được tìm thấy </div>
	<form name="frmListSp" method="post" action="?mod=news.listcomment&method=del" onSubmit="return checkInput(this,'Bạn hãy chọn ít nhất một giá trị','Bạn chắc chắn muốn xoá không');">
	<input type="hidden" name="chon" />
	<table width="100%" border="1" bordercolor="#B2DAEE" cellpadding="4">
		<tr class="newsList-content-head">
		<td width="4%" class="newsList-content-view"><input type="checkbox" name="chkall" value="0" <? if($isexits) echo "onClick=\"docheck(this.form,0);\""?>></td>
			<td width="13%" class="newsList-content-title">Người gửi</td>

		  <td width="24%" class="newsList-content-view"><div align="center">Tin tức</div></td>
		  <td width="38%" class="newsList-content-view"><div align="center">Nội dung </div></td>
		  <td width="13%" class="newsList-content-view"><div align="center">Ngày gửi</div></td>
			<td width="8%" class="newsList-content-position">Tùy chọn</td>
		</tr>
				<?
				while($rows = mysql_fetch_array($rs))
				{
					$i++;
					$cm_id = $rows['cm_id'];
					$cm_nguoidung = $rows['cm_nguoidung'];
					$cm_tintuc_id = $rows['cm_tintuc_id'];
					$cm_content = $rows['cm_content'];
					$cm_date = $rows['cm_date'];
				?>				
		<tr onmouseover="this.bgColor='#FEF2CB';" onmouseout="this.bgColor='#FFFFFF';" class="newsList-content-list" <? if($i%2==0) echo "bgcolor='#f2fff2'";?>>
			<td class="newsList-content-title"><input type="checkbox" name="Xoa" value="<?=$cm_id?>" onClick="docheckone(this.form);"></td>
			<td class="newsList-content-title">
            	<table cellpadding="0" cellspacing="0" width="100%">
                <tr>
					<td>
						<a class="newsList-link newsList-name" href="">
						<b><?=tenNguoiDung($cm_nguoidung);?></b></a>					</td>
                                </table>
		  </td>
			<td class="newsList-content-view"><div align="left"><?=getTinTuc($cm_tintuc_id);?></div></td>
			<td class="newsList-content-view"><div align="left"><?=substr($cm_content,0,150);?></div></td>
			<td class="newsList-content-view"><div align="center"><?=format_date($cm_date);?></div></td>
			<td class="newsList-content-position">
				<a href="?mod=news.listcomment&amp;method=delete&amp;id=<?=$cm_id?>" class="menu" onclick="return confirm('Bạn có chắc chắn muốn xóa không?')"><img src="images/delete_on.gif" border="0" /></a></td>
        </tr>
		<? }?>
	<tr>
   <td colspan="8" align="center">
   <input type="submit" name="submit" value="   Xoá   " class="Button">
   <input type="reset" value="Làm lại" class="Button">
   </td>
   </tr>
</table></form>
	<div class="newsList-pagging">
	<div class="raovat-paging-bound">
	<span style="padding:5px;">
	<p align="center" class="font">
			<?php echo page_div( "?mod=news.listcomment&p=%d_pg", "10", ceil ( $numofpages ), $page ); ?>
	</p>
	</span>
	</div>
	</div>
	<div class="newsList-button-back"><a href="javascript: history.back()">[Quay lại]</a></div>